package logger;

import java.io.IOException;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import conf.PropReaderWriter;

public class ApplicationLogger {


	private static Logger logger = null;

	public static Logger getLogger(){
		if(logger==null){
			logger = Logger.getLogger("SportScoutingLogger");
			FileHandler fh;
			try {
				String logFile = PropReaderWriter.getProperty("log_file");
				fh = new FileHandler(logFile, true);
				logger.addHandler(fh);
				logger.setLevel(Level.ALL);
				SimpleFormatter formatter = new SimpleFormatter();
				fh.setFormatter(formatter);
				
			} catch (SecurityException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;

			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
				return null;

			}


		}
		return logger;
	}

	
	public static void main(String[] args){
		
		ApplicationLogger.getLogger().log(Level.ALL, "FileSystemDndTree.drop()");
		
	}

}
